package com.avic.modules.mapping.rest;

import com.avic.modules.mapping.domain.DataMapping;
import com.avic.modules.mapping.service.DataMappingService;
import com.avic.modules.mapping.service.dto.DataMappingQueryCriteria;
import com.avic.modules.mapping.service.mapper.DataMappingMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.redisson.Redisson;
import org.redisson.api.RLock;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.TimeUnit;

/**
 * @author zhangzikang
 * @date 2022-08-14
 */
@Api(tags = "设备管理: 点位接口")
@RestController
@RequestMapping("/api/equipment/data_mapping")
@AllArgsConstructor
public class DataMappingController {

    private final DataMappingService dataMappingService;

    /**
     * 查看设备对应点位信息
     * @param criteria
     * @return
     */
    @ApiOperation("查看设备对应点位信息")
    @GetMapping
    public ResponseEntity<Object> getEquipmentDataMapping(DataMappingQueryCriteria criteria){
        return new ResponseEntity<>(dataMappingService.selectDataMapping(criteria), HttpStatus.OK);
    }

    /**
     * 修改点位信息
     * @param criteria
     * @return
     */
    @ApiOperation("修改点位信息")
    @PutMapping
    public ResponseEntity<Object> eatDataMapping(@Validated @RequestBody DataMapping criteria){
        dataMappingService.eatDataMapping(criteria);
        return new ResponseEntity<>(HttpStatus.OK);
    }

}
